$(function(){
	var loginId_qq = "oe-qq";
	var loginId_weixin = "oe-weixin";
	var loginId_sina = "oe-sina";
	var clientType = localStorage.getItem("clientType");
	$(".oauth-btns a").on("click",function(){
		if(!clientType){
			layer.open({
			    content: '请选择您使用的手机客户端',
			    time: 2
			});
			return;
		}
		localStorage.setItem("clientType",clientType);
		var index = $(this).index();
		var url;
		if(index == 0){
			url = "https://graph.qq.com/oauth2.0/authorize?response_type=token&client_id=101326787&redirect_uri=http://haoyunsoon.duapp.com/author/qqoauth.html&client_type="+clientType;
		}else if(index == 1){
			url = "https://open.weixin.qq.com/connect/qrconnect?appid=wxca96bb663b735648&redirect_uri=http://haoyunsoon.duapp.com&response_type=code&scope=snsapi_login&client_type="+clientType+"#wechat";
		}else if(index == 2){
			url = "https://api.weibo.com/oauth2/authorize?scope=email&redirect_uri=http://www.cdyt8.com&response_type=code&client_id=2076584297&client_type="+clientType;
		}
		window.location.href = url;
		//window.open(url,$(this).attr("title"),"width=600,height=600,left=330,top=50")
	});

	//选择平台
	$(".platform-btns a").on("click",function(){
		$(this).addClass("active").siblings("a").removeClass("active");
		if($(this).index() == 0){
			clientType = "writenovel";
		}else{
			clientType = "lovenovel";
		}
	}); 
	if(clientType == "writenovel"){
		$(".platform-btns a").eq(0).addClass("active");
	}else if(clientType == "lovenovel"){
		$(".platform-btns a").eq(1).addClass("active");
	}
	if(!userId() || !userName()){
	    $("#userinfo-box").hide();
	}else{
		window.location.href = "mybook-list.html";
	}
	
	loadGuide(true);
})